﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class GuestBook : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = "在线留言";

    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string uname = tblName.Text;//姓名
        string title = tblTitle.Text;//标题
        string content = tblContent.Text;//留言内容
        try
        {
            DbAccess db = new DbAccess();
            string sql = "insert into GuestBook values('" + uname + "','" + title + "','" + content + "','" + DateTime.Now.ToString() + "')";
            if (db.ExecuteSql(sql))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加成功')", true);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加失败')", true);

            }
        }
        catch
        { 
        
        }
    }

    protected void btnClear_Click(object sender, EventArgs e)
    {
     tblName.Text = "";
        tblTitle.Text = "";
        tblContent.Text = "";
    }
}
